package com.shf.threads;

import javax.swing.JFrame;

public class SwingAndThread extends JFrame{

	private static final long serialVersionUID = 1L;
	private static Thread t ;
	private int count = 0 ;
	
	public SwingAndThread(){
		t = new Thread(new Runnable() {
			@Override
			public void run() {
				while (count <= 30) {
					try {
						Thread.sleep(500);
					} catch (InterruptedException e) {
						e.printStackTrace();
						System.out.println("当前线程被中断");
						break;
					}
					count++;
					if(count % 5 == 0){
						System.out.println(" count="+count);
					}
				}	
			}
		});
	
		t.start();
		t.interrupt();

	}			
		
	public static void main(String[] args) {
		new SwingAndThread();
	}	
	
}
